using NUnit.Framework;
using Rhino.Mocks;
using TestAssemblyInterfaces;

namespace LoggingMagic.Tests.Integration.StaticMethodTests
{
    [TestFixture]
    public class TestAssemblyTests
    {
        private ITestClass _target;
        private ILog _logger;

        [SetUp]
        public void Setup()
        {
            _logger = MockRepository.GenerateStrictMock<ILog>();
            Initializer.SetLogger(_logger);

            _logger.Expect(x => x.Log("TestClass..ctor", new object[] { }));

            _target = Initializer.GetTestAssemblyInstance();
        }

        [Test]
        public void MethodWithoutParameters_Logged()
        {
            _logger.Expect(x => x.Log("TestClass.TestMethod", new object[] { }));
            _target.TestMethod();

            _logger.VerifyAllExpectations();
        }

        [Test]
        public void MethodWithParameters_Logged()
        {
            _logger.Expect(x => x.Log("TestClass.TestMethodWithParam", new object[] { "asd" }));
            _target.TestMethodWithParam("asd");

            _logger.VerifyAllExpectations();
        }

        [Test]
        public void NotLoggedMethodWithParameters_NotLogged()
        {
            _target.NotLoggedMethodWithParam("asd");

            _logger.VerifyAllExpectations();
        }

        [Test]
        public void PrivateMethod_Logged()
        {
            _logger.Expect(x => x.Log("TestClass.PrivateMethod", new object[] { "asd" }));
            _target.PrivateMethodCaller("asd");

            _logger.VerifyAllExpectations();
        }

        [Test]
        public void MethodWithVars_Logged()
        {
            _logger.Expect(x => x.Log("TestClass.MethodWithPrivateVars", new object[] { "asd" }));
            _target.MethodWithPrivateVars("asd");

            _logger.VerifyAllExpectations();
        }

        [Test]
        public void TestWithReturnValue_Logged()
        {
            _logger.Expect(x => x.Log("TestClass.TestWithReturnValue", new object[] { "123" }));
            _target.TestWithReturnValue("123");

            _logger.VerifyAllExpectations();
        }

        [Test]
        public void TestMethodWithValueParam_Logged()
        {
            _logger.Expect(x => x.Log("TestClass.TestMethodWithValueParam", new object[] { 123 }));
            _target.TestMethodWithValueParam(123);

            _logger.VerifyAllExpectations();
        }

    }
}